package com.kacheap.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.kacheap.service.IOrderService;

@RestController
@RequestMapping("/state/")
public class StateController {
	@Autowired
	private IOrderService orderService;

	@GetMapping("create")
	public Object create() {
		return orderService.create();
	}

	@GetMapping("pay/{orderId}")
	public Object pay(@PathVariable(name = "orderId") int orderId) {
		return orderService.pay(orderId);
	}

	@GetMapping("deliver/{orderId}")
	public Object deliver(@PathVariable(name = "orderId") int orderId) {
		return orderService.deliver(orderId);
	}

	@GetMapping("receive/{orderId}")
	public Object receive(@PathVariable(name = "orderId") int orderId) {
		return orderService.receive(orderId);
	}
	
	@GetMapping("refund/{orderId}")
	public Object refund(@PathVariable(name = "orderId") int orderId) {
		return orderService.refund(orderId);
	}

	@GetMapping("status/{orderId}")
	public Object status(@PathVariable(name = "orderId") int orderId) {
		return orderService.getOrders().get(orderId);
	}

}
